export default class Watcher {
  constructor(vm, attValue, callback) {
    this.vm = vm;
    this.name = attValue;
    this.callback = callback;
    this.oldValue = this.vm.getValue(this.name);
    window.$watcher = this;
    vm[this.name];
    window.$watcher = null;
  }
  update() {
    this.callback(this.vm.getValue(this.name));

    let watch = this.vm.$watchs[this.name];
    if (watch) {
      watch.call(this.vm, this.vm.getValue(this.name), this.oldValue);
    }
  }
}
